package com.cdn.dns.api.factory;

import com.cdn.common.core.domain.R;
import com.cdn.dns.api.RemoteDnsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteDnsFallbackFactory implements FallbackFactory<RemoteDnsService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteDnsService.class);


    @Override
    public RemoteDnsService create(Throwable throwable) {
        log.error("域名解析服务调用失败:{}", throwable.getMessage());
        return new RemoteDnsService()
        {
            @Override
            public R<Integer> clusterBindProviders(Long clusterId,Long dnsProvidersId) {
                return R.fail("集群和服务商账号关联失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> delClusterBindProviders(Long[] clusterId) {
                return R.fail("删除集群和服务商账号关联失败:" + throwable.getMessage());
            }
        };
    }
}
